﻿using System.Collections;
using System.Collections.Generic;
using System.Linq;
using NBehave.Narrator.Framework;
using NBehave.Spec.NUnit;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;

namespace NH.OpenClosedPrinciple.SecondAttempt
{
	[Theme("OCP: Exploring Open Closed Principle[Take2]"), TestFixture]
	public class ProductFilterFixture : FixtureBase
	{
		[Test]
		public void should_be_able_to_filter_products_by_colour() {
			IList<Product> products = null;
			IEnumerable<Product> results = null;
			ProductFilter productFilter = new ProductFilter();
			ProductFilterSpecification filterSpecification = null;

			story.WithScenario("Filtering Products by Colour")
					//.Pending("Implementation")
				.Given("List of Products", () => products = base.BuildProductList())

				.When("I filter by $colour", ProductColour.Blue,
				(ProductColour color) => 
					results = productFilter.By(products, new ColorFilterSpecification(color)))

				.Then("I expect a result with a count of $count", 4,
					  (int pExpectedCount) => results.Count().ShouldEqual(pExpectedCount));
		}

		[Test]
		public void should_filter_products_by_size() {
			IList<Product> initialList = null;
			IEnumerable<Product> result = null;

			story.WithScenario("Filtering Products by Size")
				//.Pending("Implementation")
		.Given("List of Products", () => initialList = base.BuildProductList())
		.When("I filter by $size", ProductSize.Large,
		  (ProductSize size) =>
		  	{
		  		var productFilter = new ProductFilter();
		  		 result = productFilter.By(initialList, new SizeFilterSpecification(ProductSize.Large));

		  	})
		.Then("I expect a filter result of $count products", 3, 
			(int expectedCount)=> result.Count().ShouldEqual(expectedCount));
		}
	}
}

